package org.chorus;

import processing.core.PApplet;
import processing.core.PGraphics;
import jwo.landserf.structure.RasterMap;

//  **********************************************************************************
/** Interface that declares the minimum functionality required to make a modular class
 *  capable of being integrated into a Chorus GUI or report writing tool. The interface
 *  provides methods for pointing to input data sources, graphical output and basic
 *  presentation styles.
 *  @author Jo Wood
 *  @version 1.3.2, 18th March, 2013
 */
//  **********************************************************************************

/* This file is part of the Chorus river bed analysis software package. Chorus is free software:
 * you can redistribute it and/or modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * Chorus is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this
 * source code (see COPYING included with this source code). If not, see 
 * http://www.gnu.org/licenses/.
 */
public interface Modular
{
	/** Defines the options for specifying direction relative to the stream direction in any module.
	 */
	public enum Direction 
	{
		/** Indicates a downstream direction. */					DOWNSTREAM, 
		/** Indicates a cross-stream direction.*/					CROSSSTREAM,
		/** Indicates a left-to-right raster direction.*/			LEFT_TO_RIGHT,
		/** Indicates a top-to-bottom raster direction.*/			TOP_TO_BOTTOM,
		/** Indicates that all directions are to be considered. */	ALL
	}
	
	/** Should do any of the one-off initialisation required by the class before its output is displayed.
	 *  @param parent Parent Processing applet in which the modular class is embedded.
	 */
	public abstract void setup(PApplet parent);
	
	/** Should set the order number for this module. Allows a list of modules to be sorted in some arbitrary order.
	 *  @param order Order number where the smaller the number, the earlier in a sorted list the module will appear.
	 */
	public abstract void setOrder(int order);
	
	/** Should report the order number for this module. Allows a list of modules to be sorted in some arbitrary order.
	 *  @return Order number where the smaller the number, the earlier in a sorted list the module will appear.
	 */
	public abstract int getOrder();
	
	/** Should be used to set the graphics context into which all output is directed. This method allows
	 *  output to be redirected to print output, offscreen buffers etc.
	 *  @param parent New graphics context in which the modular class is embedded.
	 */
	public abstract void setGraphics(PGraphics parent);

	/** Should allow a DEM for analysis to be added to the class.
	 *  @param dem DEM to be added to those analysed by the module.
	 */
	public abstract void addDEM(RasterMap dem);
	
	/** Should set the colour palette start colour. This can be used for ensuring consistent colouring
	 *  for modules that contain a subset of all DEMs being displayed in the application.
	 *  @param offset Position in default colour palette in which the first DEM or measure is displayed.
	 */
	public abstract void setColourOffset(int offset);
	
	/** Should provide graphical output for display within the given bounds.
	 *  @param xOrigin Left-hand pixel coordinate of the area in which to provide output.
	 *  @param yOrigin Top pixel coordinate of the area in which to provide output.
	 *  @param width Width in pixels of the area in which to provide output.
	 *  @param height Height in pixels of the area in which to provide output.
	 */
	public abstract void draw(float xOrigin, float yOrigin, float width, float height);
	
	/** Should provide some text output that can be written to the given file. This may not be appropriate
	 *  for some module types, in which case this should be left as an empty method. 
	 *  @param fileName Name of output file.
	 *  @return Should be true if output is written successfully.
	 */
	public abstract boolean writeOutput(String fileName);
	
	/** Should respond to mouse press events (leave empty if no mouse responses required).
	 */
	public abstract void mousePressed();
	
	/** Should respond to mouse release events (leave empty if no mouse responses required).
	 */
	public abstract void mouseReleased();

	/** Should respond to mouse drag events (leave empty if no mouse responses required).
	 */
	public abstract void mouseDragged();
}
